# -*- coding: utf-8 -*-


class UserError(Exception):
    pass

class UserNameDuplicateError(UserError):
    
    msg = "User with name <%s> already exists"
    
    def __init__(self, name, msg=None):
        self.message = msg and (msg % name) or (self.__class__.msg % name)
        
    def __str__(self):
        return self.message     


class OneUserPerOpenidError(UserError):
    
    msg = "Only one user per openID can be created. Seems that you are registered already."
    
    def __init__(self, msg=None):
        self.message = msg or self.__class__.msg
        
    def __str__(self):
        return self.message
    
    
class UserNameInvalidError(UserError):
    
    msg = "User name <%s> is invalid"
    
    def __init__(self, name, msg=None):
        self.message = msg and (msg % name) or (self.__class__.msg % name)
        
    def __str__(self):
        return self.message
    